package day03_Socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Clint2 {
    static Socket socket = null;

    public static void main(String[] args) {
        try {
            String tc = null;
            socket = new Socket("127.0.0.1",3232);
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            PrintWriter pw = new PrintWriter(socket.getOutputStream());
            while(!(tc=br.readLine()).equals("exit")){
                System.out.println(tc);
                pw.println(tc);
                pw.flush();
            }
            pw.close();
            br.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            try {
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
